package com.symaster.common.swing.list;

import javax.swing.*;
import java.awt.*;
import java.util.List;

/**
 * @author yinmiao
 * @date 2021-08-30 08:19
 */
public class SwingTreePanel extends JPanel {

    public static final int TYPE_LEFT = 0;
    public static final int TYPE_RIGHT = 2;
    public static final int TYPE_CENTER = 1;
    public static final int TYPE_LEADING = 3;
    public static final int TYPE_TRAILING = 4;
    private final Integer elementHeight;
    private final Integer elementWidth;

    /**
     * Creates a new <code>JPanel</code> with a double buffer
     * and a flow layout.
     */
    public SwingTreePanel(Integer elementHeight, Integer elementWidth) {
        super(new FlowLayout(TYPE_LEFT, 5, 5));
        this.elementHeight = elementHeight;
        this.elementWidth = elementWidth;
    }
    /**
     * Creates a new <code>JPanel</code> with a double buffer
     * and a flow layout.
     */
    public SwingTreePanel(Integer elementHeight, Integer elementWidth, Integer hMarge, Integer vMarge) {
        super(new FlowLayout(TYPE_LEFT, hMarge, vMarge));
        this.elementHeight = elementHeight;
        this.elementWidth = elementWidth;
    }
    public SwingTreePanel(int type, Integer elementHeight, Integer elementWidth, Integer hMarge, Integer vMarge) {
        super(new FlowLayout(type, hMarge, vMarge));
        this.elementHeight = elementHeight;
        this.elementWidth = elementWidth;
    }

    public void put(Item item) {

    }

    public static abstract class Item {

        // 唯一id
        private String uuid;
        // 名称
        private String name;
        // 父对象
        private Item parent;
        // 子节点
        private List<Item> node;

        /**
         * 返回root panel
         */
        public abstract JPanel getRootPanel();

        public void setPreferredSize(Dimension preferredSize) {
            getRootPanel().setPreferredSize(preferredSize);
        }

        public void setBackground(Color bg) {
            getRootPanel().setBackground(bg);
        }

        public void selects(String uuid) {

        }

        public void select(String uuid) {

        }

        public void deSelect(String uuid) {

        }

        public void deSelects(String uuid) {

        }

        public void selectListener() {

        }

        public void deSelectListener() {

        }
    }
}
